<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
	<h:outputStylesheet library="css" name="main.css" />
</h:head>
<h:body>
	<h:form>
		<h3>#{msgs.loginHello}: #{userMB.user.name} || <h:commandLink action="#{userMB.logOut()}" value="#{msgs.logout}" /> </h3>
	
		<h:messages />
		<h:dataTable value="#{dogMB.allDogs}" var="dog" styleClass="table" headerClass="tableColumnsHeader" rowClasses="tableFirstLine,tableNextLine" >
			<h:column>
				<f:facet name="header">
					#{msgs.dogName}
				</f:facet>
				
				#{dog.name}
			</h:column>
			<h:column>
				<f:facet name="header">
					#{msgs.dogWeight}
				</f:facet>
				
				#{dog.weight}
			</h:column>
			<h:column>
				<h:panelGrid columns="2">
					<!-- Always save the id as hidden when you use a request scope MB -->
					<h:inputHidden value="#{dog.id}" />
					
					<h:commandButton action="#{dogMB.updateDogStart()}" value="#{msgs.update}" rendered="#{userMB.userAdmin}" >
						<f:setPropertyActionListener target="#{dogMB.dog}" value="#{dog}" />
					</h:commandButton>
					<h:commandButton action="#{dogMB.deleteDogStart()}" value="#{msgs.delete}" rendered="#{userMB.userAdmin}" >
						<f:setPropertyActionListener target="#{dogMB.dog}" value="#{dog}" />
					</h:commandButton>
				</h:panelGrid>
			</h:column>
		</h:dataTable>
		<!-- This button is displayed to the user, just to you see the error msg  -->
		<h:commandButton action="createDog" value="#{msgs.create} #{msgs.dog}" />
	</h:form>
</h:body>
</html>